/**
 * 右键菜单
 */
import React, {PropTypes} from 'react'
import {bindActionCreators} from 'redux'
import {connect} from 'react-redux'
import {Breadcrumb } from 'antd'
import {Link} from 'react-router'

import styles from './index.less'
export default class Context extends React.Component{
  constructor(props) {
    super(props)
    this.contextMenuClick = this.contextMenuClick.bind(this)
  }
  /**
	 * 页面渲染之前执行
	 */
  componentWillMount() {
    document.oncontextmenu=function(e){
      return false
    }
  }
  /**
	 * 页面渲染完之后执行
	 * @return {[type]} [description]
	 */
  componentDidMount(){

  }
  contextMenuClick(item){
    this.props.contextMenuClick(item)
  }
  /**
	 * 渲染页面
	 * @return {[type]} [description]
	 */
  render(){
    let data = this.props.data
    let list = []
    data.forEach((item, i)=>{
      if(!!item.href && item.href != ''){
        list.push(
          <Breadcrumb.Item><Link to={item.href}>{item.text}</Link></Breadcrumb.Item>
        )
      } else{
        list.push(
          <Breadcrumb.Item>{item.text}</Breadcrumb.Item>
        )
      }
    })
    return (
      <div className='breads'>
        <Breadcrumb>
          {list}
        </Breadcrumb>
      </div>
    )
  }
}
